﻿<UserControl x:Class="SilverlightMapCreator.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:map="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
    xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit" 
    mc:Ignorable="d"
    d:DesignHeight="456" d:DesignWidth="715">

    <Grid x:Name="LayoutRoot" Background="White" MouseLeftButtonUp="ImageHolder_MouseLeftButtonUp">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <StackPanel>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal">
                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="Message">Choose An Image</TextBlock>
                    <Button Content="Browse..." Click="BrowseClick" />
                </StackPanel>
                
                <ScrollViewer x:Name="ImageScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"  HorizontalAlignment="Stretch" MaxHeight="400">
                    <layoutToolkit:LayoutTransformer x:Name="ImageLayoutTransformer">
                        <layoutToolkit:LayoutTransformer.LayoutTransform>
                            <ScaleTransform x:Name="ImageScalTransform"/>
                        </layoutToolkit:LayoutTransformer.LayoutTransform>
                        <Image x:Name="ImageHolder" Stretch="UniformToFill" MouseRightButtonDown="ImageHolder_MouseRightButtonUp" MouseWheel="ImageHolder_MouseWheel" MouseLeftButtonDown="ImageHolder_MouseLeftButtonDown" MouseLeftButtonUp="ImageHolder_MouseLeftButtonUp" MouseMove="ImageHolder_MouseMove">
                        </Image>
                    </layoutToolkit:LayoutTransformer>
                </ScrollViewer>
            </Grid>
            <TextBlock Text="Mode: " FontWeight="Bold"/>
            <StackPanel Orientation="Horizontal">
                <RadioButton Content="Corespondances" GroupName="modeGroup" IsChecked="{Binding Path=Mode,Mode=TwoWay, Converter={StaticResource StringToEnum}, ConverterParameter=Corespondaces,FallbackValue=True}"/>
                <RadioButton Content="ColorsSelection" GroupName="modeGroup" IsChecked="{Binding Path=Mode,Mode=TwoWay, Converter={StaticResource StringToEnum}, ConverterParameter=ColorsSelection}"/>
            </StackPanel>
            <TextBlock Text="Parameters:" FontWeight="Bold"/>
           
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Search Range:"/>
                <Slider x:Name="DistanceParamSlider" Maximum="30" Minimum="0" Width="100"/>
                <TextBlock Text="{Binding Value, ElementName=DistanceParamSlider}" Width="30"/>

                <TextBlock Text="Color toleration:" Margin="10,0,0,0"/>
                <Slider x:Name="ColorParamSlider" Maximum="60" Minimum="0" Width="100"/>
                <TextBlock Text="{Binding Value, ElementName=ColorParamSlider}" Width="30"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Min points per route:"/>
                <Slider x:Name="MinPointsPerRouteSlider" Maximum="30" Minimum="0" Width="100"/>
                <TextBlock Text="{Binding Value, ElementName=MinPointsPerRouteSlider}" Width="30"/>
                <TextBlock Text="Insert Every: "/>
                <Slider x:Name="InsertEverySlider" Maximum="30" Minimum="1" Width="100"/>
                <TextBlock Text="{Binding Value, ElementName=InsertEverySlider}" Width="30"/>
            </StackPanel>
            
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Distance to connect: "/>
                <Slider x:Name="DistanceToConnectSlider" Maximum="500" Minimum="20" Width="100"/>
                <TextBlock Text="{Binding Value, ElementName=DistanceToConnectSlider}" Width="30"/>
            </StackPanel>
            
            
            <StackPanel Orientation="Horizontal">
                <Button Click="StartAnalysis_Click" Content="Start Analysis"/>
                <Button Click="ExportOsm_Click" Content="Export OSM"/>
                <Button Click="ExportBikeRoutes_Click" Content="Export Only Routes"/>
                <Button Click="OpenCorespondances_Click" Content="Open Corespondances"/>
                <Button Click="SaveCorespondances_Click" Content="Open Corespondances"/>

            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <StackPanel>
                    <ListBox ItemsSource="{Binding LocationsDictionary}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Key}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
                <StackPanel>
                    <ListBox ItemsSource="{Binding ResultDictionary}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Key}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </StackPanel>

        </StackPanel>
        <StackPanel Grid.Column="1" VerticalAlignment="Stretch">
            <map:Map CredentialsProvider="AlvQY3wmI3KvHvHhqzCw-wuEogZ8SzQs6eqvdzrBPTDLUZiIE9NcoEG_SrHE_xWG" Mode="Road" LogoVisibility="Collapsed"
                x:Name="map" Margin="3" VerticalAlignment="Stretch" MinHeight="300" MouseRightButtonDown="map_MouseRightButtonDown">
                
            </map:Map>
            <TextBlock Text="Correspondences:" FontWeight="Bold"/>
            <ListBox ItemsSource="{Binding Corespondances}" SelectedItem="{Binding SelectedCorespondance,Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Point.X, StringFormat='X: \{0:N0\}'}"/>
                            <TextBlock Text="-"/>
                            <TextBlock Text="{Binding Path=Point.Y, StringFormat='Y: \{0\}'}"/>
                            <TextBlock Text=" => " Margin="5,0,5,0"/>
                            <TextBlock Text="{Binding Path=Location.Longitude, StringFormat='Longitude: \{0\}'}"/>
                            <TextBlock Text="-"/>
                            <TextBlock Text="{Binding Path=Location.Latitude, StringFormat='Latitude: \{0\}'}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <TextBlock Text="Colors:" FontWeight="Bold"/>
            <ListBox x:Name="SelectedColorsList" ItemsSource="{Binding SelectedColors}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Rectangle Height="10" Width="10" Fill="{Binding}"/>
                            <TextBlock Text="{Binding}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </StackPanel>
        
    </Grid>
</UserControl>
